﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Xxf.IISM.Core;

namespace Xxf.IISM.Web.Controllers
{
    public class AdminTableController : AdminControllerBase
    {
        // GET: AdminTable  Html基础表格
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult JsData()
        {
            return View();
        }
        //ajax前端分页
        public ActionResult AjaxUIPage()
        {
            return View();
        }
        public JsonResult AjaxUIPage_Post()
        {
            List<object> data = new List<object>();
            for (int i = 0; i < 101; i++)
            {
                var o = new List<string>()
                {
                    i.ToString(),"Position"+i,"Office"+i,"Extn"+i,DateTime.Now.ToShortTimeString(),"Salary"+i
                };
                data.Add(o);
            }
            return Json(new { data=data});
        }
        //ajax后台分页
        public ActionResult AjaxDBPage()
        {
            return View();
        }
        public JsonResult AjaxDBPage_Post(JqTableRequest model)
        {
            List<TableData> data = new List<TableData>();
            for (int i = 0; i < 101; i++)
            {
                var o = new TableData();
                //{

                //"Name"+i,"Position"+i,"Office"+i,"Extn"+i,DateTime.Now.ToShortTimeString(),"Salary"+i
                //};
                o.Name = "Name" + i;
                o.Position = "Position" + i;
                o.Office = "Office" + i;
                o.StartDate = DateTime.Now;
                o.Extn = i.ToString();
                o.Salary = "Salary" + i;
                data.Add(o);
            }
            var d = data.AsQueryable().Page(model);
            return Json(d);
        }
        public class TableData
        {
            public string Name { get; set; }
            public string Position { get; set; }
            public string Office { get; set; }
            public string Extn { get; set; }
            public DateTime StartDate { get; set; }
            public string Salary { get; set; }
        }
    }
}